import React,{Component} from 'react'
import {connect} from 'react-redux'
import store from '../redux/store'
import {addCount, deCount,asyncAddCount} from '../redux/action'

import {Button} from 'antd'
 class Test extends Component{
    constructor(props){
        super(props)
        this.state={

        }
    }
    addCount = () => {
        const num = this.select.value * 1
        store.dispatch(addCount(num))
    }
    deCount = () => {
        const num = this.select.value * 1
        store.dispatch(deCount(num))
    }
    asyncAddCount = () => {
        const num = this.select.value * 1
        store.dispatch(asyncAddCount(num))
    }
    render (){
        let count = store.getState().counter
        console.log(count)
        return (
            <div style={{padding: '50px', background: '#fcf'}}>
                <p>{count}</p>
                <select ref={s => this.select = s}>
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                </select>
                <button onClick={this.addCount}>+&nbsp;&nbsp;</button>
                <button onClick={this.deCount}>-</button>
                <button onClick={this.asyncAddCount}>异步加</button>
                <Button type="primary">Primary</Button>
                <Button>Default</Button>
                <Button type="dashed">Dashed</Button>
                <Button type="danger">Danger</Button>
                <Button type="link">Link</Button>

            </div>
        )
    }
}
export default connect(
    state => ({count: state.counter})
)(Test)
